<template>
  <div>
    <h1>计算属性的应用</h1>
    <p>输入正确的账号密码,才能提交信息</p>
    <form action @submit.prevent="login">
      <input type="text" v-model="mobile" />
      <input type="password" v-model="password" />
      <button type="submit" :disabled="!isValided">Login</button>
    </form>
    <hr />
  </div>
</template>

<script>
// computed 的应用
export default {
  data() {
    return {
      mobile: "",
      password: ""
    };
  },
  computed: {
    isValided() {
      //电话号11位1开头 密码大于6位
      return (
        String(this.mobile).match(/^1\d{10}$/) &&
        String(this.password).length >= 6
      );
    }
  }
};
</script>

<style scoped>
</style>